feature/jackson3 native (fixes #22294)#23071
feature/jackson3 native (fixes #22294)#23071thorstenhirsch wants to merge 34 commits intoOpenAPITools:masterfrom
Conversation
There was a problem hiding this comment.
4 issues found across 304 files
Note: This PR contains a large number of files. cubic only reviews up to 75 files per PR, so some files may not have been reviewed.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="modules/openapi-generator/src/main/resources/Java/libraries/native/pom.mustache">
<violation number="1" location="modules/openapi-generator/src/main/resources/Java/libraries/native/pom.mustache:268">
P1: Potential compile failure: When useJackson3=true, jackson-databind-nullable dependency is excluded from POM, but pojo.mustache still generates JsonNullable type references if openApiNullable is enabled (default). This causes compilation errors due to missing import org.openapitools.jackson.nullable.JsonNullable.</violation>
</file>
<file name="samples/client/petstore/java/native-jackson3/build.gradle">
<violation number="1" location="samples/client/petstore/java/native-jackson3/build.gradle:87">
P2: JUnit 5 is incompletely configured - missing engine dependency and useJUnitPlatform()</violation>
</file>
<file name="modules/openapi-generator/src/main/resources/Java/libraries/native/model.mustache">
<violation number="1" location="modules/openapi-generator/src/main/resources/Java/libraries/native/model.mustache:50">
P0: Incorrect Jackson 3 annotation package imports. The `jackson-annotations` module deliberately kept `com.fasterxml.jackson.annotation.*` package in Jackson 3 for backward compatibility - only core modules moved to `tools.jackson.*`. Fix: annotation imports should remain as `com.fasterxml.jackson.annotation.*` in the useJackson3 section.</violation>
</file>
<file name="samples/client/petstore/java/native-jackson3/docs/DefaultApi.md">
<violation number="1" location="samples/client/petstore/java/native-jackson3/docs/DefaultApi.md:73">
P2: Documentation method signature contains extra 'fooGet' token, resulting in invalid Java syntax 'ApiResponse<FooGetDefaultResponse> fooGet fooGetWithHttpInfo()'. Should be 'ApiResponse<FooGetDefaultResponse> fooGetWithHttpInfo()'.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
modules/openapi-generator/src/main/resources/Java/libraries/native/model.mustache
Outdated
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/Java/libraries/native/pom.mustache
Show resolved
Hide resolved
samples/client/petstore/java/native-jackson3/docs/DefaultApi.md
Outdated
Show resolved
Hide resolved
...es/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java
Outdated
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/Java/libraries/native/build.gradle.mustache
Outdated
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/Java/libraries/native/build.gradle.mustache
Outdated
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/Java/libraries/native/pom.mustache
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/Java/libraries/native/pom.mustache
Outdated
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/Java/libraries/native/pom.mustache
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/Java/libraries/native/build.gradle.mustache
Show resolved
Hide resolved
|
I'm not sure about the JUnit 5 changes in
Sounds reasonable to me. If you don't want them here, but in a separate PR instead, I will revert them here, of course. |
|
Alright, please do another code review @cubic-dev-ai |
@thorstenhirsch I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
3 issues found across 333 files
Note: This PR contains a large number of files. cubic only reviews up to 75 files per PR, so some files may not have been reviewed.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="samples/client/petstore/java/native-jackson3/README.md">
<violation number="1" location="samples/client/petstore/java/native-jackson3/README.md:18">
P1: README incorrectly states Java 11+ requirement but Jackson 3 requires Java 17+. This documentation error will cause build/runtime failures for users following the instructions.</violation>
</file>
<file name="samples/client/petstore/java/native-jackson3/.travis.yml">
<violation number="1" location="samples/client/petstore/java/native-jackson3/.travis.yml:6">
P1: Travis CI uses JDK 11 (oraclejdk11) but Jackson 3.x requires Java 17+</violation>
</file>
<file name="modules/openapi-generator/src/main/resources/Java/libraries/native/ApiClient.mustache">
<violation number="1" location="modules/openapi-generator/src/main/resources/Java/libraries/native/ApiClient.mustache:4">
P1: JsonNullableModule is not registered when useJackson3 is enabled, breaking JsonNullable (de)serialization for models generated with openApiNullable=true</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
modules/openapi-generator/src/main/resources/Java/libraries/native/ApiClient.mustache
Outdated
Show resolved
Hide resolved
…on-databind-nullable
|
Sorry, this PR is still not ready. The generated code contains wrong imports. I'm working on it. |
|
Alright, I've fixed SerializerProvider/SerializationContext, ObjectMapper/JsonMapper issues and error handling with the new JacksonException. Now I could successfully generate a Java client with Jackson 3, all unit tests succeed. Also, I've made sure that Jackson 2 still works. Now I guess it's finally time to start with human code reviews. And sorry @robinmarechal that I've asked you too early and wasted your time. |
|
Lots of getters and setters missing in |
There was a problem hiding this comment.
1 issue found across 66 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="docs/generators/java.md">
<violation number="1" location="docs/generators/java.md:100">
P2: Documentation for useJackson3 with 'native' library is missing Java 17 requirement. Jackson 3 requires Java 17 but the documentation only mentions 'native' library requires Java 11+, misleading users who may attempt to use useJackson3 on Java 11-16.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
|
Alright, this branch is now aligned with restclient's Jackson 3.1.0, unit tests and the integration test you mentioned succeed. @wing328 |
Clarify the incompatibility of Jackson 3 with openApiNullable in the documentation.
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="docs/generators/java-microprofile.md">
<violation number="1" location="docs/generators/java-microprofile.md:100">
P2: Documentation regression: The `useJackson3` option description removes the incompatibility warning for `openApiNullable`, but the generator code (`JavaClientCodegen.java`) still silently disables `openApiNullable` when both options are enabled. This creates a documentation-to-implementation contract mismatch where users expect the combination to work but won't get the expected nullable functionality in generated code.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
...es/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java
Outdated
Show resolved
Hide resolved
...es/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
5 issues found across 31 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="samples/client/petstore/java/webclient-springBoot4-jackson3/build.gradle">
<violation number="1" location="samples/client/petstore/java/webclient-springBoot4-jackson3/build.gradle:131">
P1: The `webclient-springBoot4-jackson3` sample build.gradle replaces Jackson 3 dependencies (`tools.jackson.*:3.1.0`) with Jackson 2 dependencies (`com.fasterxml.jackson.*:2.21.1`), which breaks the sample's purpose of validating Jackson 3 compatibility. Other jackson3 samples like `restclient-springBoot4-jackson3` correctly use Jackson 3 coordinates.</violation>
</file>
<file name="samples/client/petstore/java/resttemplate-springBoot4-jackson3/build.gradle">
<violation number="1" location="samples/client/petstore/java/resttemplate-springBoot4-jackson3/build.gradle:100">
P1: Jackson 3 sample now depends on Jackson 2 artifacts, silently breaking Jackson 3 support validation coverage.</violation>
</file>
<file name="samples/client/petstore/java/webclient-springBoot4-jackson3/src/main/java/org/openapitools/client/ApiClient.java">
<violation number="1" location="samples/client/petstore/java/webclient-springBoot4-jackson3/src/main/java/org/openapitools/client/ApiClient.java:19">
P1: The jackson3 sample has been regenerated with Jackson 2 APIs instead of Jackson 3 APIs. The code changed from using `tools.jackson.*` package classes (JacksonJsonEncoder/JacksonJsonDecoder, JsonMapper) to `com.fasterxml.jackson.*` package classes (Jackson2JsonEncoder/Jackson2JsonDecoder, ObjectMapper). This invalidates the sample's purpose of testing Jackson 3.x compatibility with Spring Boot 4, as CI would falsely report Jackson 3 works when it's not actually being tested.</violation>
</file>
<file name="samples/client/petstore/java/resttemplate-springBoot4-jackson3/pom.xml">
<violation number="1" location="samples/client/petstore/java/resttemplate-springBoot4-jackson3/pom.xml:234">
P1: Sample POM 'resttemplate-springBoot4-jackson3' has been downgraded from Jackson 3 (3.1.0) to Jackson 2 (2.21.1), losing the purpose of validating Jackson 3 compatibility. Other jackson3 samples (native-jackson3, restclient-springBoot4-jackson3) correctly use Jackson 3 dependencies.</violation>
</file>
<file name="samples/client/petstore/java/resttemplate-springBoot4-jackson3/src/main/java/org/openapitools/client/RFC3339DateFormat.java">
<violation number="1" location="samples/client/petstore/java/resttemplate-springBoot4-jackson3/src/main/java/org/openapitools/client/RFC3339DateFormat.java:22">
P1: Jackson 3 sample uses incorrect namespace and Jackson 2 dependencies instead of Jackson 3. The code changed from tools.jackson (correct Jackson 3 namespace) to com.fasterxml.jackson (Jackson 2 namespace), while dependencies also reference Jackson 2.21.1. This means the 'jackson3' sample doesn't actually use Jackson 3.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
samples/client/petstore/java/webclient-springBoot4-jackson3/build.gradle
Outdated
Show resolved
Hide resolved
samples/client/petstore/java/resttemplate-springBoot4-jackson3/build.gradle
Outdated
Show resolved
Hide resolved
...ore/java/webclient-springBoot4-jackson3/src/main/java/org/openapitools/client/ApiClient.java
Outdated
Show resolved
Hide resolved
samples/client/petstore/java/resttemplate-springBoot4-jackson3/pom.xml
Outdated
Show resolved
Hide resolved
...sttemplate-springBoot4-jackson3/src/main/java/org/openapitools/client/RFC3339DateFormat.java
Outdated
Show resolved
Hide resolved
|
Feels like going 2 steps back... why do I need to cope with resttemplate and webclient reverting from Jackson 3 to Jackson 2 here? I've synced my forked repo and rebased my branch - but with no effect. Was everything up-to-date already? Seems like this is the point when I got lost regarding resttemplate/webclient. |
ac30f57 to
fc5b350
Compare
Add Jackson 3 support to java-native.
PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master(upcoming7.x.0minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)"fixes #123"present in the PR description)@bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) @karismann (2019/03) @Zomzog (2019/04) @lwlee2608 (2019/10) @martin-mfg (2023/08)
Summary by cubic
Adds opt‑in Jackson 3 support to the Java native client generator while keeping Jackson 2 as default. Fixes #22294. When enabled it requires Java 17+, improves RFC3339 date/time handling, validates option combos, and ships a
native-jackson3sample wired into CI (JDK 17/21).New Features
useJackson3: dynamic imports via{{jacksonPackage}}, switch toJsonMapperwithEnumFeature/DateTimeFeature, adoptSerializationContext, update RFC3339 module/Instant deserializer, better anyOf/oneOf, handleJacksonException, remove unusedIOException, fixmapper.copy().jackson-annotations2.21; addjava-native-jackson3config andsamples/client/petstore/java/native-jackson3; include sample insamples-java-client-jdk17workflow; add JDK HttpClient test; enable JUnit 5 anduseJUnitPlatform()innative/native-asyncGradle builds.useJackson3withopenApiNullable, or with unsupported libraries); clarify support matrix (supported fornative, and forrestclientwithuseSpringBoot4=true); removeuseJackson3fromresttemplate/webclientconfigs and refresh samples; fix duplicated method names in generatedWithHttpInfodocs.Migration
native, setadditionalProperties.useJackson3=trueandopenApiNullable=false(requires Java 17+). Forrestclient, support requiresuseSpringBoot4=true.useJackson3is incompatible withopenApiNullableand not supported forresttemplateorwebclient; the generator now fails on these combinations.Written for commit f45392e. Summary will update on new commits.